/* -*- C++ -*- */

//=============================================================================
/*
 * @author Feloweria <380374483@qq.com>
 * Copyright (C) Feloweria
 * 
 * $ID 2013-06-26 05:22:03 PM
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * @version 1.0
 */
//=============================================================================

#ifndef FELOWRIA_THREAD_INCLUDE
#define FELOWRIA_THREAD_INCLUDE

#include "Felowria.h"
#include "Base/DateTime.h"
#include "Log/Log.h"

#ifdef __LINUX__
	#include <pthread.h>
	#include <sched.h>
	#include <signal.h>
#endif


#ifdef __WINDOWS__
	#include <windows.h>
#endif

FELOWRIA_BEGIN

#ifdef __LINUX__
typedef pthread_t	ThreadID;
#endif

#ifdef __WINDOWS__
typedef DWORD	ThreadID;
#endif
inline ThreadID  CurThreadID()
{
#ifdef __LINUX__
	return pthread_self();
#endif

#ifdef __WINDOWS__
	return GetCurrentThreadId();
#endif
}

void DLL_EXPORT Wait(TimeValue value);

class DLL_EXPORT Thread
{
public:
	Thread();
	virtual ~Thread();
	
public:
	

public:
	bool ExcuteTask();

protected:
	virtual bool Excute() = 0;

private:
	Thread(const Thread&);
	
protected:
	ThreadID tid;

};// class Thread

FELOWRIA_END

#include "Thread.inl"

#endif // FELOWRIA_THREAD_INCLUDE
